<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form layui-form-pane1" method="post" enctype="multipart/form-data">
        <table class="layui-table">
            <tr>
                <td colspan="4" style="font-size: 20px;font-weight: bold;">申诉信息</td>
            </tr>
            <tr>
                <td style="width: 10%;">司机手机号</td>
                <td style="width: 40%;"><?php if(!empty($appealInfo['driver_phone'])):?><?php echo $appealInfo['driver_phone'];?><?php endif;?></td>
                <td style="width: 10%;">申诉城市</td>
                <td><?php echo $appealInfo['dressName'];?></td>
            </tr>
            <tr>
                <td style="width: 10%;">申诉金额</td>
                <td><?php echo $appealInfo['appeal_price'];?></td>
                <td style="width: 10%;">申诉说明</td>
                <td>
                    <?php if(!empty($appealInfo['appeal_desc'])):?>
                    <?php echo $appealInfo['appeal_desc'];?>
                    <?php else:?>
                    -
                    <?php endif;?>
                </td>
            </tr>
            <tr>
                <td style="width: 10%;">申诉时间</td>
                <td><?php echo date('Y-m-d H:i:s',$appealInfo['appeal_time']);?></td>
                <td style="width: 10%;">申诉次数</td>
                <td>
                    <?php if($appealInfo['appeal_num'] == 1):?>
                        一次申请
                    <?php else:?>
                        <span style="color: red">二次申请</span>
                    <?php endif;?>
                </td>
            </tr>
            <tr>
                <td style="width: 10%;">申诉凭证</td>
                <td colspan="3" class="layer-photos-demo">
                    <?php if(!empty($appealInfo['appeal_proof'])):?>
                    <?php foreach($appealInfo['appeal_proof'] as $key=>$value):?>
                    <img layer-src="{$value}" alt="凭证{$key+1}" src="{$value}">
                    <?php endforeach;?>
                    <?php endif;?>
                </td>
            </tr>
        </table>
        <?php if($appealInfo['appeal_num'] > 1):?>
        <table class="layui-table">
            <tr>
                <td colspan="10" style="font-size: 20px;font-weight: bold;">申诉记录明细</td>
            </tr>
            <tr>
                <td style="text-align: center;width: 6%">申诉ID</td>
                <td style="text-align: center;width: 12%">申诉说明</td>
                <td style="text-align: center;width: 11%">申诉时间</td>
                <td style="text-align: center;width: 13%">申诉次数</td>
                <td style="text-align: center;width: 13%">申诉凭证</td>
                <td style="text-align: center;width: 8%">处理结果</td>
                <td style="text-align: center;width: 20%">处理信息</td>
                <td style="text-align: center;width: 10%">处理时间</td>
            </tr>
            <?php foreach($appealInfo['appealList'] as $key=>$value):?>
            <tr>
                <td style="text-align: center"><?php echo $value['appeal_id'];?></td>
                <td style="text-align: center"><?php echo $value['appeal_desc'];?></td>
                <td style="text-align: center"><?php echo date("Y-m-d H:i:s",$value['appeal_time']);?></td>
                <td style="text-align: center"><?php echo $value['appeal_num'];?> 次</td>
                <td style="text-align: center" class="layer-photos-demo">
                    <?php if(!empty($value['appeal_proof'])):?>
                    <?php foreach($value['appeal_proof'] as $kly=>$vml):?>
                    <img layer-src="{$vml}" alt="凭证{$kly+1}" src="{$vml}">
                    <?php endforeach;?>
                    <?php endif;?>
                </td>
                <td style="text-align: center">
                    <?php if($value['appeal_status'] == 1):?>
                    申诉成功
                    <?php else:?>
                    申诉失败
                    <?php endif;?>
                </td>

                <td style="text-align: center"><?php echo $value['fail_reason'];?></td>
                <td style="text-align: center"><?php echo date("Y-m-d H:i:s",$value['dispose_time']);?></td>
            </tr>
            <?php endforeach;?>
        </table>
        <?php endif;?>
        <table class="layui-table">
            <tr>
                <td colspan="10" style="font-size: 20px;font-weight: bold;">异常订单信息</td>
            </tr>
            <?php if(!empty($appealInfo['orderInfo'])):?>
            <tr>
                <td style="text-align: center;width: 6%">订单ID</td>
                <td style="text-align: center;width: 12%">订单号</td>
                <td style="text-align: center;width: 11%">上车时间</td>
                <td style="text-align: center;width: 13%">出发地点</td>
                <td style="text-align: center;width: 13%">目的地点</td>
                <td style="text-align: center;width: 8%">实际里程</td>
                <td style="text-align: center;width: 20%">异常原因</td>
                <td style="text-align: center;width: 10%">订单金额</td>
            </tr>
            <tr>
                <td style="text-align: center"><?php echo $appealInfo['orderInfo']['common_id'];?></td>
                <td style="text-align: center;"><?php echo $appealInfo['orderInfo']['order_sn'];?></td>
                <td style="text-align: center"><?php echo date("Y-m-d H:i:s",$appealInfo['orderInfo']['on_car_time']);?></td>
                <td style="text-align: center"><?php echo $appealInfo['orderInfo']['start_name'];?></td>
                <td style="text-align: center"><?php echo $appealInfo['orderInfo']['arrive_name'];?></td>
                <td style="text-align: center"><?php echo $appealInfo['orderInfo']['real_distance']/1000;?>（KM）</td>
                <td style="text-align: center;"><?php echo $appealInfo['orderInfo']['abnormal_reason'];?></td>
                <td style="text-align: center"><?php echo $appealInfo['orderInfo']['need_price']/100;?></td>
            </tr>
            <?php else:?>
            <tr>
                <td colspan="10">未查到异常单信息</td>
            </tr>
            <?php endif;?>
        </table>
        <?php if($appealInfo['appeal_status'] > 0):?>
        <table class="layui-table">
            <tr>
                <td colspan="4" style="font-size: 20px;font-weight: bold;">处理反馈</td>
            </tr>
            <tr>
                <td style="width: 10%;">处理人</td>
                <td><?php echo $appealInfo['dispose_name'];?></td>
                <td style="width: 10%;">处理时间</td>
                <td>
                    <?php if(!empty($appealInfo['dispose_time'])):?>
                    <?php echo $appealInfo['dispose_time'];?>
                    <?php else:?>
                    -
                    <?php endif;?>
                </td>
            </tr>
            <?php if($appealInfo['appeal_status'] == 1):?>
            <tr>
                <td style="width: 10%;">申诉结果</td>
                <td style="width: 40%;">申诉成功</td>
                <td style="width: 10%;">申诉操作</td>
                <td>
                    <?php if($appealInfo['appeal_opra'] == 1):?>
                    解除异常
                    <?php else:?>
                    <span style="color: red">订单罚款</span>
                    <?php endif;?>
                </td>
            </tr>
            <?php if($appealInfo['appeal_opra'] == 1):?>
            <tr>
                <td style="width: 10%;">解冻金额</td>
                <td style="width: 40%;" colspan="3"><?php echo $appealInfo['unfreeze_price'];?></td>
            </tr>
            <?php else:?>
            <tr>
                <td style="width: 10%;">罚款金额</td>
                <td style="width: 40%;"><?php echo $appealInfo['penalty'];?></td>
                <td style="width: 10%;">罚款时间</td>
                <td>
                    <?php if(!empty($appealInfo['fine_time'])):?>
                    <?php echo $appealInfo['fine_time'];?>
                    <?php else:?>
                    -
                    <?php endif;?>
                </td>
            </tr>
            <tr>
                <td style="width: 10%;">解冻金额</td>
                <td style="width: 40%;" colspan="3"><?php echo $appealInfo['unfreeze_price'];?></td>
            </tr>
            <?php endif;?>
            <?php else:?>
            <tr>
                <td style="width: 10%;">申诉结果</td>
                <td style="width: 40%;" style="color: red">申诉失败</td>
                <td style="width: 10%;">失败原因</td>
                <td><?php echo $appealInfo['fail_reason'];?></td>
            </tr>
            <?php endif;?>

        </table>
        <?php else:?>
        <table class="layui-table">
            <tr>
                <td colspan="4" style="font-size: 20px;font-weight: bold;">申诉处理</td>
            </tr>
            <tr>
                <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                    <input type="text" class="layui-input" readonly value="申诉结果" style="border: 0px;width: 12%;float:left;background:#F8F8F8">
                    <input type="checkbox" data-type="appealType" lay-skin="switch" lay-filter="switchCheck" class="check" lay-text="通过|拒绝" value="2">
                    <input type="hidden" name="appeal_status" id="appeal_status" value="2" >
                </td>
            </tr>
            <tr id="reason" class="reason">
                <td style="width: 10%;">未通过原因</td>
                <td>
                    <textarea rows="3" class="layui-textarea" name="fail_reason" id="fail_reason" placeholder="请输入未通过原因" style="width: 500px;"></textarea>
                </td>
            </tr>
            <tr style="display: none" class="penalty">
                <td style="width: 10%;text-align: center;">罚款金额</td>
                <td><input type="text" name="penalty" id="penalty_tt" class="layui-input" placeholder="请输入罚款金额(元)" style="width: 500px;" onkeyup="num(this)"></td>
            </tr>
            <tr>
                <td colspan="3" style="padding-left: 100px;">
                    <input type="hidden" value="<?php echo $appealInfo['appeal_id'];?>" name="appeal_id" id="appeal_id">
                    <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
            </tr>
        </table>
        <?php endif;?>
    </form>
    <!--
    <form class="layui-form" action="{:url('appealChange')}" method="post" enctype="multipart/form-data">
        <div class="layui-row">
            <div style="background: #cccccc;">
                <input type="text" class="layui-input" readonly value="申诉详情" style="border: 0px;background:#F8F8F8">
            <div class=" layui-col-sm6 layui-col-md4" style="margin-bottom: 15px">
                所属城市：  {$data['region']}
            </div>
            <div class="layui-col-xs6 layui-col-sm6 layui-col-md4" style="margin-bottom: 15px">
                申诉日期： {:date('Y/m/d H:i:s',$data['appeal'][0]['appeal_time'])}
            </div>
            <div class=" layui-col-sm6 layui-col-md4" style="margin-bottom: 15px">
                司机手机号:  {$data['appeal'][0]['driver_phone']}
            </div>
            <div class=" layui-col-sm6 layui-col-md4" style="margin-bottom: 15px">
                申诉状态:  {$data['appeal'][0]['appeal_status']|appealStatus}
            </div>
                <div class=" layui-col-sm12 layui-col-md12" style="margin-bottom: 15px">
                    申诉金额：  {$data['appeal'][0]['appeal_price']/100}
                </div>
                <div class=" layui-col-sm12 layui-col-md12" style="margin-bottom: 15px">
                    实际冻结金额：  {$data['money']}
                </div>
                <div class="layui-col-sm1 layui-col-md3" style="margin-bottom: 15px">
                    申诉说明第二次：
                </div>
                <div class=" layui-col-sm11 layui-col-md12" style="margin-bottom: 15px">
                <textare class="layui-textarea">{$data['appeal'][0]['appeal_desc']}</textare>
                </div>
                <if $data['appeal'][1]['appeal_id']>
                <div class="layui-col-sm1 layui-col-md3" style="margin-bottom: 15px">
                    申诉说明第一次：
                </div>
                <div class=" layui-col-sm11 layui-col-md12" style="margin-bottom: 15px">
                    <textare class="layui-textarea">{$data['appeal'][1]['appeal_desc']}</textare>
                </div>
                </if>
                <div class="layui-col-sm1 layui-col-md3" style="margin-bottom: 15px">
                    申诉凭证：
                </div>
                <div class=" layui-col-sm11 layui-col-md12 layer-photos-demo" style="margin-bottom: 15px">
                    <if isset($data['appeal'][0]['appeal_proof'][0])>
                    <img src="{$data['appeal'][0]['appeal_proof'][0]}"  width="10%">
                    </if>
                    <if isset($data['appeal'][0]['appeal_proof'][1])>
                    <img src="{$data['appeal'][0]['appeal_proof'][1]}" width="10%">
                    </if>
                    <if isset($data['appeal'][0]['appeal_proof'][2])>
                    <img src="{$data['appeal'][0]['appeal_proof'][2]}" width="10%">
                    </if>
                </div>
            </div>
            <input type="hidden" name="appeal_id" value="{$data['appeal'][0]['appeal_id']}">
            <input type="hidden" name="driver_id" value="{$data['appeal'][0]['driver_id']}">
            <input type="hidden" name="order_id" value="{$data['order']['common_id']}">
            <input type="hidden" name="money" value="{$data['money']}">
            <input type="hidden" name="order_type" value="1">
            <input type="hidden" name="appeal_price" value="{$data['appeal'][0]['appeal_price']/100}">
            <input type="hidden" name="num" value="{$data['appeal'][0]['appeal_num']}" >

            <div>
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>

                    <thead>
                    <input type="text" class="layui-input" readonly value="申诉订单信息" style="border: 0px;background:#F8F8F8">
                    <tr>
                        <th>订单ID</th>
                        <th>订单类型</th>
                        <th>订单号</th>
                        <th>是否异常</th>
                        <th>异常原因</th>
                        <th>上车时间</th>
                        <th>起点</th>
                        <th>终点</th>
                        <th>里程（公里）</th>
                        <th>金额（元）</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{$data['order']['common_id']}</td>
                        <td>{$data['order']['order_type']}</td>
                        <td>{$data['order']['order_sn']}</td>
                        <td>{$data['order']['abnormal_order']==0?"否":"是"}</td>
                        <td>{$data['order']['abnormal_reason']}</td>
                        <td>{:date('Y/m/d H:i:s',$data['order']['on_car_time'])}</td>
                        <td>{$data['order']['start_name']}</td>
                        <td>{$data['order']['arrive_name']}</td>
                        <td>{$data['order']['real_distance']/1000}</td>
                        <td>{$data['order']['need_price']/100}</td>
                    </tr>
                    </tbody>
                </table>
            </div>

            <div>
                <table class="layui-table">
                    <colgroup>
                        <col width="150">
                        <col width="200">
                        <col>
                    </colgroup>

                    <thead>
                    <input type="text" class="layui-input" readonly value="处理记录" style="border: 0px;background:#F8F8F8">
                    <tr>
                        <th>ID</th>
                        <th>申诉结果</th>
                        <th>失败原因</th>
                        <th>解冻金额</th>
                        <th>罚款金额</th>
                        <th>处理人</th>
                        <th>处理时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{$data['appeal'][0]['appeal_id']}</td>
                        <td>{$data['appeal'][0]['appeal_status']|appealStatus}</td>
                        <td>{$data['appeal'][0]['fail_reason']}</td>
                        <td>{$data['appeal'][0]['unfreeze_price']/100}</td>
                        <td>{$data['appeal'][0]['penalty']/100}</td>
                        <td>{$data['appeal'][0]['dispose_name']}</td>
                        <td>{:date('Y/m/d H:i:s',$data['appeal'][0]['dispose_time'])}</td>
                    </tr>
                    <if $data['appeal'][1]['appeal_id']>
                    <tr>
                        <td>{$data['appeal'][1]['appeal_id']}</td>
                        <td>{$data['appeal'][1]['appeal_status']|appealStatus}</td>
                        <td>{$data['appeal'][1]['fail_reason']}</td>
                        <td>{$data['appeal'][1]['unfreeze_price']/100}</td>
                        <td>{$data['appeal'][1]['penalty']/100}</td>
                        <td>{$data['appeal'][1]['dispose_name']}</td>
                        <td>{:date('Y/m/d H:i:s',$data['appeal'][1]['dispose_time'])}</td>

                    </tr>
                    </if>
                    </tbody>
                </table>
            </div>
        </div>
        <if $data['appeal'][0]['appeal_status']==0 >
        <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="申诉结果" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="appeal_status" data-type="checkResult" id="shenhe" lay-skin="switch" lay-filter="switchCheck" class="check" lay-text="通过|未过" value=1 <?php if($info['appeal_status'] == 2):?>checked<?php endif;?>>
                            </td>
                        </tr>
                        <tr id="reason" class="reason">
                            <td style="width: 10%;text-align: center;">未通过原因</td>
                            <td>
                                <textarea rows="3" class="layui-textarea" name="fail_reason" id="fail_reason"  maxlength="80" placeholder="请输入未通过原因"><?php echo $info['fail_reason'];?></textarea>
                            </td>
                        </tr>
                        <tr style="display: none" class="penalty">
                            <td style="width: 10%;text-align: center;">罚款金额</td>
                            <td><input type="text" name="penalty" placeholder="请输入罚款金额(元)"></td>
                        </tr>
                    </table>

        <button class="layui-btn" lay-submit="" id="submit"  lay-filter="submit">提交</button>
        </if>
    </form>-->
    <script>
        layui.use(['form'], function(){
            var form = layui.form,layer = layui.layer;
            layer.photos({
                photos: '.layer-photos-demo'
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                ,tab: function(pic, layero){

                }
            });
            //异常申请处理结果
            form.on('switch(switchCheck)', function(data){
                if(!this.checked){
                    var value = 1;
                }else{
                    var value = 2;
                }
                var key_name = $(this).data('type');
                if(key_name == 'appealType'){                       //充值入口
                    if(value == 1){
                        $('#appeal_status').val(2);
                        $('.reason').css('display', '');
                        $('.penalty').css('display', 'none');
                    }else{
                        $('#appeal_status').val(1);
                        $('.penalty').css('display', '');
                        $('.reason').css('display', 'none');
                    }
                }
            });
            //异常单申请处理结果数据提交
            form.on('submit(*)', function (data) {
                $.ajax({
                    url:'{:url("/admin/DriverService/appealChange")}',
                    async:true,
                    dataType:'json',
                    type:'POST',
                    data: $(data.form).serialize(),
                    success:function(res){
                        if(res.code==1){
                            layer.alert(res.msg, {icon: 6},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload()
                            });
                        }else{
                            layer.msg(res.msg,{icon: 5});
                        }
                    }
                });
                return false;

            })
        });
        //验证只能输入数字
        function num(object) {
            var value   = object.value;
            var id      = object.id;
            if (isNaN(value)){
                layer.msg('请输入正确的数字',{icon: 5});
                $("#"+id).val('');
                return false;
            }
        }
    </script>
</block>
